﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autofac;
using Autofac.Builder;
using ProgramShortcuts.Components.Services;
using ProgramShortcuts.Components.Functions;
using Autofac.Configuration;

namespace ProgramShortcuts
{
	public class Bootstrap
	{
		public static IContainer Components(){
			var builder = new ContainerBuilder();			
			
			builder.Register<ConsoleClearScreen>().As<IClearScreen>().SingletonScoped();
			builder.Register<ConsoleWriteString>().As<IWriteString>().SingletonScoped();
						
			builder.Register<AlarmFunctionState>().As<IFunctionState>().Named( "AlarmFunctionState" );
			builder.Register<NewLineFunctionState>().As<IFunctionState>().Named( "NewLineTransition" );
			builder.Register<CalculatorFunctionState>().As<IFunctionState>().Named( "CalculatorTransition" );


			builder.Register<IConsoleInputService>(
				c => new ConsoleInputServiceImpl(
					new IFunctionState[]{
			            c.Resolve<IFunctionState>("AlarmFunctionState"),
			            c.Resolve<IFunctionState>("NewLineTransition"),
			            c.Resolve<IFunctionState>("CalculatorTransition")
			        } ) );

			return builder.Build();
		}
	}
}
